package org.example.product.service.impl;

import org.example.product.entity.ResultBody;
import org.example.product.mapper.SearchMapper;
import org.example.product.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SearchServiceimpl implements SearchService {
    @Autowired
    private SearchMapper searchMapper;
    @Override
    public List<Map<String,Object>> searchByName(String name) {
        List<Map<String,Object>> list=searchMapper.searchByName(name);
        if(!list.isEmpty())
        {
            return list;
        }
        return null;
    }
    @Override
    public List<Map<String,Object>> searchByKind(String kind) {
        List<Map<String,Object>> list=searchMapper.searchByKind(kind);
        if(!list.isEmpty())
        {
            return list;
        }
        return null;
    }

    @Override
    public ResultBody searchGoodsByPrice(double minprice, double maxprice) {
        List<Map<String,Object>> list=searchMapper.searchGoodsByPrice(minprice,maxprice);
        if(!list.isEmpty())
        {
            return new ResultBody(200,"查询成功",list,list.size());
        }
        return new ResultBody(400,"暂无商品",false);
    }

}
